#ifndef METADATAEDITOR_H
#define METADATAEDITOR_H

#include<QAbstractButton>
#include<QCheckBox>
#include<QDialog>
#include<QDialogButtonBox>
#include<QFormLayout>
#include<QHBoxLayout>
#include<QIntValidator>
#include<QLabel>
#include<QLineEdit>
#include<QList>
#include<QMessageBox>
#include<QString>
#include<QTabWidget>
#include<QTimer>
#include<QVBoxLayout>
#include<QWidget>

#include<taglib/taglib.h>
#include<taglib/fileref.h>

class LFMCorrection;

class MetaDataEditor: public QDialog{
Q_OBJECT
public:
	MetaDataEditor(QList<QString> songPaths);
	~MetaDataEditor();
	static void launchEditor(QList<QString> songPaths);
	static void launchEditorForCorrection(LFMCorrection *correction);
	static void addCallbackOnChange( void (*callbackOnChange)(void*,QList<QString>), void *obj );
private slots:
	void slotButtonClicked(QAbstractButton *button);
	void slotAutoNumberingChanged(int state);
	void slotGlobalArtistChanged(QString newArtist);
	void slotGlobalArtistStateChanged(int state);
	void slotGlobalAlbumChanged(QString newAlbum);
	void slotGlobalAlbumStateChanged(int state);
	void slotAnythingChanged();
private:
	QVBoxLayout *m_layout;
	QTabWidget *m_tabWidget;
	
	QWidget *m_editWidgetGlobal;
	QFormLayout *m_editLayoutGlobal;
	QLineEdit *m_editArtistGlobal;
	QLineEdit *m_editAlbumGlobal;
	QCheckBox *m_editTrackGlobal;
	
	QList<QWidget*> m_editWidget;
	QList<QFormLayout*> m_editLayout;
	QDialogButtonBox *m_buttons;
	QList<TagLib::FileRef> m_fileRef;
	QList<TagLib::Tag*> m_tag;
	QList<QLineEdit*> m_editTitle;
	QList<QLineEdit*> m_editArtist;
	QList<QLineEdit*> m_editAlbum;
	QList<QLineEdit*> m_editTrack;
	
	QTimer *m_autoExitTimer;
	static QList<void (*)(void*,QList<QString>)> s_callbacksOnExit;
	static QList<void*> s_callbackObjects;
	
	void initGlobalEditor();
	
	void buttonOk();
private slots:
	void buttonCancel();
private:
	bool buttonApply();
	
	void applyCorrection(LFMCorrection *correction);
	void setTimer(qint64 duration);
	static void _addMorePathsToCorrection(QList<QString> &songPaths, LFMCorrection *correction);
};

#endif
